package com.gxa.logistics.service.impl;

import com.github.pagehelper.PageHelper;
import com.gxa.logistics.common.base.PageWrapperDTO;
import com.gxa.logistics.common.base.RespResult;
import com.gxa.logistics.common.util.PageResultUtil;
import com.gxa.logistics.domain.dto.*;
import com.gxa.logistics.domain.vo.EmployeeVO;
import com.gxa.logistics.domain.vo.MessionVO;
import com.gxa.logistics.mapper.EmployeeMapper;
import com.gxa.logistics.mapper.MessionMapper;
import com.gxa.logistics.service.EmployeeService;
import com.gxa.logistics.service.MessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;

@Service
public class MessionServiceImpl implements MessionService {
    @Autowired
    private MessionMapper messionMapper;

    @Override
    public RespResult<PageWrapperDTO<MessionVO>> list(MessionReqListDTO messionReqListDTO) {
        // 使用分页插件
        PageHelper.startPage(messionReqListDTO.getPageNo(),messionReqListDTO.getPageSize());
        // 包装的分页返回对象
        PageWrapperDTO<MessionVO> pageCommon = new PageWrapperDTO<>();
        List<MessionVO> messionList = messionMapper.findMessionByWhere(messionReqListDTO);
        // 设置分页返回对象
        PageResultUtil.setPageResult(messionList,pageCommon);
        return RespResult.success(pageCommon);
    }

    @Override
    public void insertMession(MessionSaveDTO messionSaveDTO) {
        messionMapper.insertMession(messionSaveDTO);
    }

    @Override
    public void updateMession(MessionUpdateDTO messionUpdateDTO) {
        messionMapper.updateMession(messionUpdateDTO);
    }

    @Override
    public void deleteMessionByLpnumAndDate(String lpnum, Date date) {
        messionMapper.deleteMessionByLpnumAndDate( lpnum, date);
    }
}
